package com.dog.view.controller;

import com.dog.model.Region;
import com.dog.service.IRegionService;
import com.dog.spring.ServiceFactory;
import com.dog.view.beans.BaseBean;
import com.dog.view.beans.RegionBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.context.WebApplicationContext;

import javax.annotation.PostConstruct;
import javax.faces.model.SelectItem;

/**
 * User: Kuttubek Aidaraliev
 * Date: 06.05.2010
 * Time: 9:21:17
 */
@Controller
@Scope(value= WebApplicationContext.SCOPE_REQUEST)
public class RegionBeanController extends BaseBeanController<IRegionService, Region, RegionBean> {

    @Autowired
    private IRegionService regionService;

    public RegionBeanController() {
    }

    @PostConstruct
    protected void initialized(){
       regionService = ServiceFactory.getRegionService();
       setService(regionService);
    }

    @Override
    public String list() {
        return "regionList";
    }

    @Override
    protected String form() {
        return "region";
    }

    @Override
    protected Region newEntity() {
        return new Region();
    }

    @Override
    protected SelectItem createSelectItem(Region region) {
        return new SelectItem(region, region.getTitle());  
    }

    @Override
    protected String getNameEntity() {
        return "regionBean";
    }

    @Override
    protected RegionBean createEntityBean() {
        return new RegionBean();
    }

    public String currentPage(){
        return null;
    }
}
